import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
// import 'element-plus/lib/theme-chalk/index.css';
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import axios from "axios";
import * as echarts from 'echarts'
import Antd from 'ant-design-vue';
import ProductActivationList from "@/components/ProductActivationList.vue";
import UserOption from "@/components/user/UserOption.vue";
import { createPinia } from 'pinia';
import 'ant-design-vue/dist/antd.css';
import 'amfe-flexible'
// export const app = createApp(App)

import {
    Popover,
    Radio, RadioGroup,
    Slider
} from 'ant-design-vue'

axios.defaults.baseURL = process.env.VUE_APP_URL;
//axios拦截器
axios.interceptors.request.use(function (config) {
    console.log("请求参数", config);
    return config;
}), (error: any) => {
    return Promise.reject(error);
}
axios.interceptors.response.use(function (response) {
    console.log("返回结果", response);
    return response;
}), (error: any) => {
    console.log("返回错误:", error)
}

let Vue: any = createApp(App)
Vue.directive('tableInfiniteScroll', {
    mounted(el, binding) {
        let tbody = el.querySelector(".el-table__body-wrapper");
        el.tableInfiniteScrollFn = function () {
            if (this.scrollHeight - this.scrollTop - parseInt(this.style.height) == 0) {
                binding.value();
            }
        };
        tbody.addEventListener("scroll", el.tableInfiniteScrollFn);
        tbody = undefined;
    },
    unmounted(el, binding) {
        let tbody = el.querySelector(".el-table__body-wrapper");
        tbody.removeEventListener("scorll", el.tableInfiniteScrollFn);
        el.tableInfiniteScrollFn = undefined;
    }
})
Vue.component('ProductActivationList', ProductActivationList)
Vue.component('UserOption', UserOption)
Vue.component('Popover', Popover)
Vue.component('Radio', Radio)
Vue.component('RadioGroup', RadioGroup)
Vue.component('Slider', Slider)
Vue.use(router).use(ElementPlus).use(Antd).use(createPinia()).mount('#app')


